#include "ConditionalStatement.h"

ConditionalStatement::ConditionalStatement(BooleanStatement * conditional, ConditionalStatement * thenConditional, ConditionalStatement * elseConditional)
{
	printf("making ConditionalStatement 1\n");
	this->conditional = conditional;
	this->thenConditional = thenConditional;
	this->elseConditional = elseConditional;
	this->thenString = NULL;
	this->elseString = NULL;
}
ConditionalStatement::ConditionalStatement(BooleanStatement * conditional, ConditionalStatement * thenConditional, char * elseString)
{
	printf("making ConditionalStatement 2\n");
	this->conditional = conditional;
	this->thenConditional = thenConditional;
	this->elseConditional = NULL;
	this->thenString = NULL;
	this->elseString = elseString;
}
ConditionalStatement::ConditionalStatement(BooleanStatement * conditional, char * thenString, ConditionalStatement * elseConditional)
{
	printf("making ConditionalStatement 3\n");
	this->conditional = conditional;
	this->thenConditional = NULL;
	this->elseConditional = elseConditional;
	this->thenString = thenString;
	this->elseString = NULL;
}
ConditionalStatement::ConditionalStatement(BooleanStatement * conditional, char * thenString, char * elseString)
{
	printf("making ConditionalStatement 4\n");
	this->conditional = conditional;
	this->thenConditional = NULL;
	this->elseConditional = NULL;
	this->thenString = thenString;
	this->elseString = elseString;
}
	
char * ConditionalStatement::Evaluate(Dictionary * dictionary)
{
	if(conditional && conditional->Evaluate(dictionary))
	{
		if(thenConditional)
		{
			return thenConditional->Evaluate(dictionary);
		}
		return thenString;
	}
	if(elseConditional)
	{
		return elseConditional->Evaluate(dictionary);
	}
	return elseString;
}

		